home *** CD-ROM | disk | FTP | other *** search
- Path: castle.nando.net!news
- From: actuary@nando.net (Bill McCarthy)
- Newsgroups: comp.lang.c
- Subject: Re: cpp question
- Date: 21 Jan 1996 16:41:49 GMT
- Organization: News & Observer Public Access
- Message-ID: <4dtqcd$8r5@castle.nando.net>
- References: <4drm99$j0m@peabody.colorado.edu>
- Reply-To: actuary@nando.net (Bill McCarthy)
- NNTP-Posting-Host: vyger315.nando.net
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <4drm99$j0m@peabody.colorado.edu>,
- woodjr@rintintin.Colorado.EDU (WOOD JAMEY RYAN) writes:
-
- >I have something like this:
- >
- > #define USERLEN 8
- > #define HOSTLEN 15
- >
- > char name[] = "woodjr";
- > char host[] = "really.long.hostname.com";
- > char s[100];
- >
- > sprintf(s, "%.USERLENs@%.HOSTLENs", name, host);
- >
- >And I want cpp to parse the sprintf line to:
- >
- > sprintf(s, "%.8s@%.15s", name, host);
-
- Try it like this:
-
- sprintf(s, "%.*s@%.*s", USERLEN, name, HOSTLEN, host);
-
- Bill McCarthy
- actuary@nando.net
- Wendell, NC USA
-
-